package com.magic.gre.adapter;

import android.content.Context;
import android.view.View;

import com.magic.gre.R;
import com.magic.gre.entity.Guide3Bean;
import com.noname.lib_base_java.adapter.CommonAdapter;
import com.noname.lib_base_java.adapter.ViewHolder;
import com.noname.lib_base_java.util.SelectHelper;

import java.util.List;

/**
 * Author: Lmoumou
 * Date: 2019-01-11 17:57
 * 文件名: Guide3Adapter
 * 描述:
 */
public class Guide3Adapter extends CommonAdapter<Guide3Bean> {

    private OnItemClickListener onItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }

    public Guide3Adapter(Context mContext, List<Guide3Bean> mData) {
        super(mContext, mData, R.layout.item_guide3);
    }

    @Override
    protected void bindData(ViewHolder holder, int position) {
        final Guide3Bean bean = mData.get(position);
        holder.setText(R.id.mButton, bean.getContent());

        holder.getView(R.id.mButton).setSelected(bean.isSelect());
        holder.getView(R.id.mButton).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener!=null){
                    SelectHelper.selectAllSelectBeans(mData, false);
                    bean.setSelect(true);
                    notifyDataSetChanged();
                    onItemClickListener.onItemClick();
                }

            }
        });


    }

    public interface OnItemClickListener{
        void onItemClick();
    }
}
